package com.codinghero.example.jdk.lock.condition;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class ConditionExample {

	static final Lock LOCK = new ReentrantLock();
	static final Condition CONDITION = LOCK.newCondition();

	public static void main(String[] args) {
		try {
			Thread t = new Thread(new PrintThread());
			t.start();
			TimeUnit.MILLISECONDS.sleep(100);
			LOCK.lock();
			CONDITION.signal();
		} catch (InterruptedException e) {
			e.printStackTrace();
		} finally {
			LOCK.unlock();
			System.out.println("end");
		}
	}
}
